package it.giuseppetrisciuoglio.lyrics.persistence.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Version;

@Entity
@Table(name="TB_ERRORE")
public class Errore extends CommonClass implements Serializable {

	private static final long serialVersionUID = -1491215074082017154L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	Long id;
	
	@Column(name="NUM_ARTISTA")
	Long artistaId;
	
	@Column(name="NUM_CANZONE")
	Long canzoneId;
	
	@Column(name="TXT_URL")
	String url;
	
	@Column(name="TXT_ERRORE")
	String error;
	
	@Column(name="TXT_TRANSACTION_CODE")
	String transactionCode;
	
	@Lob
	@Column(name="TXT_ERRORE_DETAIL")
	String errorTrace;
	
	@Lob
	@Column(name="TXT_RESPONSE")
	String response;
	
	@Version
	@Column(name="NUM_VERSION")
	Long version;
	
	@Column(name="TS_ERROR_DATE")
	Date errorDate;
	
	@PrePersist
	public void error(){
		errorDate = new Date();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}

	public Long getVersion() {
		return version;
	}

	public void setVersion(Long version) {
		this.version = version;
	}

	public Date getErrorDate() {
		return errorDate;
	}

	public void setErrorDate(Date errorDate) {
		this.errorDate = errorDate;
	}

	public Long getArtistaId() {
		return artistaId;
	}

	public void setArtistaId(Long artistaId) {
		this.artistaId = artistaId;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getErrorTrace() {
		return errorTrace;
	}

	public void setErrorTrace(String errorTrace) {
		this.errorTrace = errorTrace;
	}

	public String getTransactionCode() {
		return transactionCode;
	}

	public void setTransactionCode(String transactionCode) {
		this.transactionCode = transactionCode;
	}

	public Long getCanzoneId() {
		return canzoneId;
	}

	public void setCanzoneId(Long canzoneId) {
		this.canzoneId = canzoneId;
	}

	public String getResponse() {
		return response;
	}

	public void setResponse(String response) {
		this.response = response;
	}

	@Override
	public String toString() {
		return "Errore [url=" + url + ", error=" + error + ", transactionCode=" + transactionCode + "]";
	}
	
}
